<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of m_proyecto
 *
 * @author konda
 */
class m_proyecto extends CI_Model{
    //put your code here
    
    var $table="sc_pyto";
    
    public function __construct() {
        parent::__construct();
     $this->table="sc_pyto";
          
    }
    
    
    public function getList()
    {
       $query= $this->db->get($this->table);
       return $query->result();
    }
    
    /**
     * Add register proyecto 
     * 
     * @param type $data array
     */
    public function add($data)
    {
        $query=$this->db->insert($this->table,$data);
        
    }
   
    /**
     * Get last row inserted
     * @return type
     */
    public function getRowLastInsert()
    {
        //get last id
        $last_id=$this->getIdLastInsert();
        //select row last insert
        $this->db->where("id",$last_id);
        $query=$this->db->get($this->table);
        return $query->result();        
    }
    
    
    public function getRowCount()
    {
       $query= $this->db->get($this->table);
       return $query->num_rows();
       
    }
    
    /**
     * Get last insert id
     * @return type
     */
    public function getIdLastInsert()
    {
        return $this->db->insert_id();
    }
    
    /**
     * Delete row for id of the table
     * @param type $id
     */
    public function delete($id)
    {
        $this->db->where("id",$id);
        $this->db->delete($this->table);
        
    }
    
    /**
     * Update table
     * @param type $id
     * @param type $data
     */
    public function update($id,$data)
    {
      $this->db->where("id",$id);
      $this->db->update($this->table,$data);
    }
    
    
    
    
           
    
    
    
}

?>
